import { defineStore } from "pinia";
import { ref, computed } from "vue";

export const useUserStore = defineStore('user', () => {
  const userInfo = ref({});

  const token = ref('')
  const hasLogin = computed(() => !!token.value)

  // 清空仓库
  function clear() {
    userInfo.value = {}
    token.value = ''
  }

  return {
    userInfo,
    token,
    hasLogin,
    clear
  }
}, {
  unistorage: true
})